package fr.umlv.projet.android.utils;

import java.io.File;
import java.io.IOException;

public class FileUtils {

	/**
	 * Delete file or folder (recursive method).
	 */
	public static void delete(File file) throws IOException {
		if (file.isDirectory()) {
			if (file.list().length == 0) {
				file.delete();
			}
			else {
				for (String temp : file.list()) {
					File fileDelete = new File(file, temp);
					delete(fileDelete);
				}
				if (file.list().length == 0) {
					file.delete();
				}
			}

		}
		else {
			file.delete();
		}
	}

}
